package com.ruoyi.web.controller.system.factory;

import com.ruoyi.common.core.domain.entity.SysDictData;
import com.ruoyi.system.service.ISysDictTypeService;
import com.ruoyi.web.core.JoController;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * 系统 字典工厂
 *
 * @author Jyl
 */
@Component
public class SysDictFactory extends JoController
{

    @Autowired
    private ISysDictTypeService sysDictTypeService;

    /**
     * @param dictType 字典类型
     * @return 字典枚举转换
     */
    public Map<String, String> dict(String dictType)
    {
        List<SysDictData> data = sysDictTypeService.selectDictDataByType(dictType);
        Map<String, String> map = new HashMap<>();
        for (SysDictData datum : data)
        {
            map.put(datum.getDictLabel(), datum.getDictValue());
        }
        return map;
    }

}
